﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "data source =.; Initial Catalog =MyDB_O;Integrated security =True;";
            SqlConnection connection = new SqlConnection(connectionString);

            string query = "select ID, Name, LastName from MyTable";
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                Console.WriteLine(reader ["ID"]);
                Console.WriteLine(reader["Name"]);
                Console.WriteLine(reader["LastName"]);
                Console.WriteLine("=================");
            }
            connection.Close();
        }
    }
}
